		**********************************************************
		** File: Table_G3.do									**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Creating Table G3								**
 		**********************************************************
 
	clear
	version 16.1
	set seed 1234

	cd "~"
 
 
				 *******************************
				 *** DISCRIMINATION PARAMETER **
				 *** (ALPHAS)   			  **
				 *******************************
	 
	 ** STATIC **
	 
	clear
	import delimited "static_alphas.csv" 
		order v1
	rename v1 var
	sort c1_mean
	
	replace c2_mean="" if c2_mean=="NA"
	replace c3_mean="" if c3_mean=="NA"	
	replace c4_mean="" if c4_mean=="NA"
	destring c2_mean, replace
	destring c3_mean, replace	
	destring c4_mean, replace
	gen x= c2_mean - c1_mean if v1=="u_vict_5"
	gen x2= c3_mean - c2_mean if v1=="u_vict_5"
	gen x3= c4_mean - c3_mean if v1=="u_vict_5"
 
 
	gen upper=c1_mean + (1.96*c1_sd)
	gen lower=c1_mean - (1.96*c1_sd)
  
	browse var c1_mean  c1_025 c1_975
	browse var c2_mean  c2_025 c2_975
	browse var c3_mean  c3_025 c3_975		
	browse var c4_mean  c4_025 c4_975
	
 	
	
	*** DYNAMIC ***

	cd "~"	
	
	** DEST **
	import delimited "dynamic_dest_alpha.csv", encoding(Big5) clear 	
 	rename v1 year
	rename v2 dest_a_mean
	rename v3 dest_a_25
	rename v4 dest_a_75
	egen mean=mean(dest_a_mean)
	egen d_low=mean(dest_a_25)
	egen d_high=mean(dest_a_75)	
	browse mean d_low d_high
 	
	
	** LDEST **
	import delimited "dynamic_ldest_alphas.csv", encoding(Big5) clear 	
 	rename v1 year
	rename v2 ldest_a_mean
	rename v3 ldest_a_25
	rename v4 ldest_a_75
	egen lmean=mean(ldest_a_mean)
	egen ld_low=mean(ldest_a_25)
	egen ld_high=mean(ldest_a_75)	
	browse lmean ld_low ld_high 	
		
	** PDEST **
	import delimited "dynamic_pdest_alphas.csv", encoding(Big5) clear 	
 	rename v1 year
	rename v2 pdest_a_mean
	rename v3 pdest_a_25
	rename v4 pdest_a_75
	egen pmean=mean(pdest_a_mean)
	egen pd_low=mean(pdest_a_25)
	egen pd_high=mean(pdest_a_75)	
 	browse pmean pd_low pd_high
	
	** DDEST **
	import delimited "dynamic_ddest_alphas.csv", encoding(Big5) clear 	
 	rename v1 year
	rename v2 ddest_a_mean
	rename v3 ddest_a_25
	rename v4 ddest_a_75
	egen dmean=mean(ddest_a_mean)
	egen dd_low=mean(ddest_a_25)
	egen dd_high=mean(ddest_a_75)	
	browse dmean dd_low dd_high 		
	
	** DSDEST **
	import delimited "dynamic_dsdest_alphas.csv", encoding(Big5) clear 	
 	rename v1 year
	rename v2 dsdest_a_mean
	rename v3 dsdest_a_25
	rename v4 dsdest_a_75
	egen dsmean=mean(dsdest_a_mean)
	egen dsd_low=mean(dsdest_a_25)
	egen dsd_high=mean(dsdest_a_75)	
 	browse dsmean dsd_low dsd_high	
	
	** CLDEST **
	import delimited "dynamic_cldest_alphas.csv", encoding(Big5) clear 	
 	rename v1 year
	rename v2 cldest_a_mean
	rename v3 cldest_a_25
	rename v4 cldest_a_75
	egen clmean=mean(cldest_a_mean)
	egen cld_low=mean(cldest_a_25)
	egen cld_high=mean(cldest_a_75)	
 	browse clmean cld_low cld_high	
	
	** CPDEST **
	import delimited "dynamic_cpdest_alphas.csv", encoding(Big5) clear 	
 	rename v1 year
	rename v2 cpdest_a_mean
	rename v3 cpdest_a_25
	rename v4 cpdest_a_75
	egen cpmean=mean(cpdest_a_mean)
	egen cpd_low=mean(cpdest_a_25)
	egen cpd_high=mean(cpdest_a_75)	
	browse cpmean cpd_low cpd_high 

	** EVENTS **
	import delimited "dynamic_event_alphas.csv", encoding(Big5) clear 	
	browse v1 c1_mean c1_9 c1_0   if v1=="u_vict_5"
	browse v1 c2_mean c2_9 c2_0   if v1=="u_vict_5"	
	browse v1 c3_mean c3_9 c3_0   if v1=="u_vict_5"		
	browse v1 c4_mean c4_9 c4_0   if v1=="u_vict_5"			
 	
	browse v1 c1_mean c1_9 c1_0   if v1=="c_vic_5"
	browse v1 c2_mean c2_9 c2_0   if v1=="c_vic_5"	
	browse v1 c3_mean c3_9 c3_0   if v1=="c_vic_5"		
	browse v1 c4_mean c4_9 c4_0   if v1=="c_vic_5"			
	
	browse v1 c1_mean c1_9 c1_0   if v1=="c_labor_5"
	browse v1 c2_mean c2_9 c2_0   if v1=="c_labor_5"	
	browse v1 c3_mean c3_9 c3_0   if v1=="c_labor_5"		
	browse v1 c4_mean c4_9 c4_0   if v1=="c_labor_5"	
	
	browse v1 c1_mean c1_9 c1_0   if v1=="c_sex_5"
	browse v1 c2_mean c2_9 c2_0   if v1=="c_sex_5"	
	browse v1 c3_mean c3_9 c3_0   if v1=="c_sex_5"		
	browse v1 c4_mean c4_9 c4_0   if v1=="c_sex_5"		
	
  
					***************************		
					** DIFFICULTY PARAMETER ***
					** (Betas)  			***
					***************************
	
	** STATIC **
	
	clear
	import delimited "static_betas.csv"
 
	rename v1 variable
	rename v2 mean
	rename v3 lower
	rename v4 upper
	browse
				
	*** DYNAMIC  ***

	cd "~"
	
	** DEST ***
	import delimited "dynamic_dest_beta.csv", encoding(Big5) clear 	
	egen dest_mean=mean(x)
	egen dest_025=pctile(x), p(2.5)	
	egen dest_975=pctile(x), p(97.5)	
	sum dest_mean
	sum dest_025
	sum dest_975
 
	** LDEST ***
	import delimited "dynamic_ldest_beta.csv", encoding(Big5) clear 	
	egen ldest_mean=mean(x)
	egen ldest_025=pctile(x), p(2.5)	
	egen ldest_975=pctile(x), p(97.5)		
 	sum ldest_mean
	sum ldest_025
	sum ldest_975
	
	** PDEST ***
	import delimited "dynamic_pdest_beta.csv", encoding(Big5) clear 	
	egen pdest_mean=mean(x)
	egen pdest_025=pctile(x), p(2.5)	
	egen pdest_975=pctile(x), p(97.5)		
 	sum pdest_mean
	sum pdest_025
	sum pdest_975
 
	** DDEST ***
	import delimited "dynamic_ddest_beta.csv", encoding(Big5) clear 	
	egen ddest_mean=mean(x)
	egen ddest_025=pctile(x), p(2.5)	
	egen ddest_975=pctile(x), p(97.5)		
	sum ddest_mean
	sum ddest_025
	sum ddest_975	
 
	** DSDEST ***
	import delimited "dynamic_dsdest_beta.csv", encoding(Big5) clear 	
	egen dsdest_mean=mean(x)
	egen dsdest_025=pctile(x), p(2.5)	
	egen dsdest_975=pctile(x), p(97.5)		
 	sum dsdest_mean
	sum dsdest_025
	sum dsdest_975	
	
	** CLDEST ***
	import delimited "dynamic_cldest_beta.csv", encoding(Big5) clear 	
	egen cldest_mean=mean(x)
	egen cldest_025=pctile(x), p(2.5)	
	egen cldest_975=pctile(x), p(97.5)		
 	sum cldest_mean
	sum cldest_025
	sum cldest_975		
	
	** CPDEST ***
	import delimited "dynamic_cpdest_beta.csv", encoding(Big5) clear 	
	egen cpdest_mean=mean(x)
	egen cpdest_025=pctile(x), p(2.5)	
	egen cpdest_975=pctile(x), p(97.5)		
 	sum cpdest_mean
	sum cpdest_025
	sum cpdest_975		
	
	** events 
	import delimited "dynamic_betas_5.csv", encoding(Big5) clear 	
 	rename v1 variable
	rename v2 event_mean
	rename v3 event_25
	rename v4 event_975
	browse		
 
	
	
	
	 
